package com.scuec.tourismwebsite.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.tourismwebsite.entity.WeatherForecast;

import com.scuec.tourismwebsite.mapper.WeatherForecastMapper;
import com.scuec.tourismwebsite.vo.ViewWeatherForecastWithCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
//
@Service
public class WeatherForecastServicelmpl implements WeatherForecastService{

    @Autowired
    private WeatherForecastMapper weatherForecastMapper;

    public WeatherForecastServicelmpl(WeatherForecastMapper weatherForecastMapper) {
        this.weatherForecastMapper = weatherForecastMapper;
    }



    @Override
    public List<ViewWeatherForecastWithCity> findWeatherForecastWithCity() {
        return weatherForecastMapper.findWeatherForecastWithCity();
    }

    @Override
    public PageInfo<ViewWeatherForecastWithCity> findWeatherForecastPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage( pageNum,pageSize);
        List<ViewWeatherForecastWithCity> lists=weatherForecastMapper.findWeatherForecastWithCity();
        PageInfo<ViewWeatherForecastWithCity> pageInfo=new PageInfo<>(lists);
        return pageInfo;
    }


    @Override
    public Integer insertWeatherForecast(WeatherForecast weatherForecast) {
        return weatherForecastMapper.insertWeatherForecast(weatherForecast);
    }

    @Override
    public Integer updateWeatherForecast(WeatherForecast weatherForecast) {
        return weatherForecastMapper.updateWeatherForecast(weatherForecast);
    }

    @Override
    public Integer deleteWeatherForecast(Integer forecast_id) {
        return weatherForecastMapper.deleteWeatherForecast(forecast_id);
    }


    /*
    @Override
    public List<ViewWeatherForecastWithCity> findWeatherForecastByCityAndDate(String city_name, String province, Date forecast_date) {
        return weatherForecastMapper.findWeatherForecastByCityAndDate(city_name,province,forecast_date);
    }*/

}

